package com.wc.fortnight_blue_bridge.Q241116.铠甲合体;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @Author congge
 * @Date 2024/11/16 20:41
 * @description
 * https://www.lanqiao.cn/problems/20030/learning/?contest_id=223
 */
public class Main {
    /**
     * 思路：进制数, 从大到小分解
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N], b = new int[N];
    static long[] sum = new long[N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= m; i++) b[i] = sc.nextInt();
        Arrays.sort(a, 1, n + 1);
        Map<Integer, Integer> map = new TreeMap<>(Comparator.reverseOrder());
        for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
        int num = a[1], s = 0;
        for (int i = 1; i <= n; i++){
            if (num == a[i]) s++;
            else {
                map.put(num, s);
                num = a[i];
                s = 1;
            }
        }
        map.put(num, s);
        for (int i = 1; i <= m; i++){
            long res = 0;
            long x = b[i];
            for (int key : map.keySet()){
                long d = Math.min(x / key, map.get(key));
                res += d;
                x -= d * key;
            }
            if (x > 0) out.print(-1 + " ");
            else out.print(res + " ");
        }
        out.println();

//        暴力， 过 70 %
//        for (int i = 1; i <= m; i++) {
//            if (b[i] % a[1] != 0) out.print(-1 + " ");
//            else {
//                int res = dfs(0, n, b[i]);
//                out.print(res + " ");
//                map.put(b[i], res);
//            }
//        }
        out.flush();
    }
    // 暴力超时
    static int dfs(int u, int R, int x){
        if (x == 0) return u;
        if (sum[R] < x) return -1;
        int l = 1, r = R;
        while (l < r){
            int mid = l + r + 1 >> 1;
            if (a[mid] <= x) l = mid;
            else r = mid - 1;
        }
        for (int i = r; i >= 1; i--) {
            int res = dfs(u + 1, i - 1, x - a[i]);
            if (res != -1) return res;
            if (sum[i] < x) break;
        }
        return -1;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

